﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SvnNotes
{
    public class CommandLineOption
    {
        public string Name { get; set; }
        public int ArgIndex { get; set; }
        public string Value { get; set; }
        public CommandLineOption()
        {

        }

        public static CommandLineOption GetOption(string argName)
        {
            string[] args = Environment.GetCommandLineArgs();

            var arg = args.Select((item, index) => new CommandLineOption() { ArgIndex = index, Name = item })
                    .Where(x => x.Name == argName).FirstOrDefault();

            if (arg != null)
            {
                if (arg.ArgIndex + 1 < args.Length)
                {
                    arg.Value = args[arg.ArgIndex + 1];
                }
            }
            return arg;
        }
    }
 
}
